// console.show();
// toast("OK,Laixi Autox.js");

auto.waitFor()
// console.show();
// sleep(random(5000, 700));

// var appName = "抖音";
// click(appName)
sleep(random(1000, 2000));
搜索直播()
sleep(random(3000, 4000));
搜索直播()

function 搜索直播() {
	sleep(random(3000, 4000));

	click(975, 164)
	sleep(random(3000, 4000));
	var chatBox = id("et_search_kw").findOne();
	chatBox.setText("沧海一舟");
	sleep(random(3000, 4000));
	click(977, 169) //搜索
	sleep(random(2000, 3000));
	click(567, 1212)

	sleep(random(2000, 3000));
	douYinAutoCommentZhiBo()

	sleep(random(80000, 90000));
	back()
	sleep(random(1000, 2000));
	back()
	sleep(random(1000, 2000));
	back()
	sleep(random(1000, 2000));
	back()
	sleep(random(1000, 2000));
	back()
	sleep(random(1000, 2000));
	back()
	sleep(random(1000, 2000));
	click(970, 2191) //我
	sleep(random(1000, 1500));
	click(250, 700) //新朋友
	sleep(random(2000, 1500));
	if (text('查看全部').exists()) {
		text('查看全部').findOne().click()
		console.log('触发');
	}
	sleep(random(1000, 1500));
	//关注
	huguan()
	sleep(random(1000, 1500));
	swipe(random(500, 600), random(1500, 1800), random(500, 600), random(400, 500), random(300, 490))
	sleep(random(1000, 1500));
	//关注
	huguan()
	sleep(random(1000, 1500));
	back()
	sleep(random(1000, 1500));
	click(100, 2190)
	sleep(random(500, 1000));
}

function huguan() {
	while (true) {
		var target = text("回关").findOnce()
		if (target == null) {
			// toast("任务完成");
			break;
		}
		target.click();
		sleep(3000);
		 
	}
}

function douYinAutoCommentZhiBo() { //直播评论发布
	try {
		let randomIndex = 1;
		if (randomIndex == 1) {

			let comment = '关注，关注，关注，关注，关注，关注，关注，关注，关注，关注，关注，关注，关注'
			console.log(comment);
			if (className("android.widget.EditText").id("fom").exists()) {

				let clickResult = className("android.widget.EditText").id("fom").findOnce().click();
				if (clickResult) {
					sleep(1000);
					// console.log(text('说点什么...').findOnce());

					if (className("android.widget.ImageView").desc("[爱心]").exists()) {

						let b = className("android.widget.ImageView").desc("[爱心]").findOnce().bounds(); //获取评论按钮的rect
						if (click(b.centerX(), b.centerY())) {
							sleep(1000);
							setText(0, comment);
							console.log(text("发送").exists());
							if (text("发送").exists()) {
								text("发送").findOnce().click();
								3
							}
							// back();
							sleep(1000);
						}
					}
				}
			}
		}
	} catch (error) {
		console.error(error);
	}
}

function 滑动() {
	sleep(random(1000, 2000));
	var x1 = random(500, 600)
	var y1 = random(2000, 2100)
	var x2 = random(500, 600)
	var y2 = random(350, 450)
	console.log(x1, y1, x2, y2);
	swipe(x1, y1, x2, y2, random(500, 600))
}






exit()
var CommentKeyWord = [
	'酷库酷库'
];
// douYinAutoComment()
//抖音发布评论
function douYinAutoComment() {
	try {
		let randomIndex = 1;
		if (randomIndex == 1) {
			let comment = CommentKeyWord[Math.floor(Math.random() * CommentKeyWord.length)];
			if (className("android.widget.EditText").id("cxi").exists()) {
				let clickResult = className("android.widget.EditText").id("cxi").findOnce().click();
				if (clickResult) {
					sleep(3000);
					if (className("android.widget.ImageView").desc("表情").exists()) {
						let b = className("android.widget.ImageView").desc("表情").findOnce().bounds(); //获取评论按钮的rect
						if (click(b.centerX(), b.centerY())) {
							sleep(1000);
							setText(0, comment);
							if (className("android.widget.ImageView").id("q1").exists()) {
								className("android.widget.ImageView").id("q1").findOnce().click();
								3
							}
							back();
							sleep(1000);
						}
					}
				}
			}
		}
	} catch (error) {
		console.error(error);
	}
}





guanzhu()
sleep(random(1000, 2000));
点赞()
sleep(random(1000, 2000));
收藏()
console.log('下');

function guanzhu() { //关注
	click(988, 1060) //952 1024  1024 1096
}

function 点赞() { //点赞
	click(984, 1183) //936 1135 1044 1243
}

function 收藏() {
	click(990, 1594) //897 1513 1077 1685
}

exit()